﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Fermat
{
    class Program
    {
        static void Main(string[] args)
        {
            //判断是否存在满足费马大定理的三个数
            bool boolean = false;
            //将立方数从小到大导入一个数组
            long[] cubic = new long[10000];
            long num = 1;
            
            while(num<10000)
            {
                cubic[num] = (long)Math.Pow(num, 3);
                num++;
            }
            
            //用双指针遍历数组，判断是否会有满足条件的数
            for(long i=cubic.Length-1;i>0;i--)
            {
                long left = 0;
                long right = i-1;
                while(left<right+1)
                {
                    if (cubic[right] + cubic[left] == cubic[i])
                    {
                        boolean = true;
                        break;
                    }
                    else if (cubic[right] + cubic[left] < cubic[i])
                        left++;
                    else
                        right--;
                    
                }
                if (boolean)
                {
                    Console.WriteLine(cubic[i] + cubic[left] == cubic[right]);
                    Console.Write(i + " " + left + " " + right);
                    break;
                }
            }
            
            Console.WriteLine("存在10000以内的三个立方数使得其中一个等于另外两个的和的命题为");
            //输出判断结果
            Console.Write(boolean);
            Console.ReadKey();
        }

    }
}
